<template>
  <div id="labelUserTop">
    <h1 class="con-right-title">
      用户标签管理
    </h1>
    <div class="search-box">
      <el-form
        ref="ruleForm"
        :inline="true"
        :model="formInline"
        :rules="rules"
        class="demo-form-inline"
      >
        <el-form-item label="标签数" prop="conditions">
          <el-select v-model="formInline.conditions" clearable>
            <el-option
              v-for="item in conditionsList"
              :key="item.key"
              :label="item.key"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label prop="tagsNumber">
          <el-input-number
            v-model="formInline.tagsNumber"
            size="small"
            :min="1"
            :controls="false"
            placeholder="请输入标签数"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="用户搜索" prop="searchType">
          <el-select v-model="formInline.searchType" clearable>
            <el-option
              v-for="item in searchTypeList"
              :key="item.key"
              :label="item.key"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label prop="searchContent">
          <el-input
            v-model="formInline.searchContent"
            placeholder="请输入"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item class="s-btn">
          <el-button
            type="success"
            icon="el-icon-search"
            @click="toSearch('ruleForm')"
          >
            查询
          </el-button>
          <el-button type="success" plain @click="reset">
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'LabelUserTop',
  msg: '用户标签管理-顶部搜索',
  props: {
    formInline: {
      type: Object,
      default: function() {
        return {
          conditions: '',
          tagsNumber: undefined,
          searchType: '',
          searchContent: ''
        }
      }
    }
  },
  data: function() {
    return {
      conditionsList: [
        // 用户状态
        { key: '大于', value: '>' },
        { key: '大于等于', value: '>=' },
        { key: '小于', value: '<' },
        { key: '小于等于', value: '<=' },
        { key: '等于', value: '=' },
        { key: '不等于', value: '!=' }
      ],
      searchTypeList: [
        // 用户状态
        { key: '用户ID', value: 'USERID' },
        { key: '大鹏号', value: 'DAPENGNUMBER' },
        { key: '手机号', value: 'MOBILE' }
      ],
      rules: {
        conditions: {},
        searchType: {},
        searchContent: {}
      }
    }
  },
  mounted() {},
  methods: {
    /* 搜索 */
    toSearch(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('toSearch')
        } else {
          return false
        }
      })
    },
    /* 重置 */
    reset() {
      this.$refs['ruleForm'].resetFields()
      this.formInline.tagsNumber = undefined
    }
  }
}
</script>

<style lang="less">
#labelUserTop {
  .search-box {
    padding-left: 30px !important;
    .el-input-number .el-input__inner {
      text-align: left;
    }
  }
}
</style>
